package com.wsoft.system.controller;

import com.wsoft.response.ResponseResult;
import com.wsoft.system.query.member.MemberOrgPostQuery;
import com.wsoft.system.query.member.MemberOrgRoleQuery;
import com.wsoft.system.service.ISysMemberOrgRoleRelationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 人员组织用户关联表 前端控制器
 * @author zgk
 * @since 2024年09月23日 15:16:07
 */
@RestController
@Tag(name = "人员组织角色管理")
@RequestMapping("/sys/memberOrgRoleRelation")
public class SysMemberOrgRoleRelationController {
    @Resource
    private ISysMemberOrgRoleRelationService memberOrgRoleRelationService;
    @Operation(summary = "新增人员组织角色关系",description = "新增人员组织角色关系")
    @PostMapping("/insert")
    public ResponseResult insert(@RequestBody @Valid MemberOrgRoleQuery query) {
        memberOrgRoleRelationService.insertRelationByMemberId(query);
        return ResponseResult.success("[sys.msg.success]");
    }
    @Operation(summary = "修改人员组织角色关系",description = "修改人员组织角色关系")
    @PostMapping("/update")
    public ResponseResult update(@RequestBody @Valid MemberOrgRoleQuery query) {
        memberOrgRoleRelationService.updateRelationByMemberId(query);
        return ResponseResult.success("[sys.msg.success]");
    }

    @Operation(summary = "获取人员组织角色关系列表",description = "获取人员组织角色关系列表")
    @GetMapping("/get")
    public ResponseResult get(@RequestParam("memberId") Long memberId) {
        return ResponseResult.success(memberOrgRoleRelationService.getRelationByMember(memberId));
    }
}
